/********************************************************************************
 * @Author: Zhenzhou Liu
 * @Date: 2024-12-28
 * @Description: Cg图论练习之二部图最大匹配（匈牙利算法）
 *******************************************************************************/

#include<iostream>
#include<vector>

using namespace std;

bool dfsFindAlterPaths(vector<vector<int>> &adj, vector<int>& matched, vector<bool>& visited, int u) {
    for(int v : adj[u]) {
        if (!visited[v]) {
            visited[v] = true;
            if (matched[v] == 0 || dfsFindAlterPaths(adj, matched, visited, matched[v])) {
                matched[v] = u;
                return true;
            }
        }
    }
    return false;
}

int maxPartiteMatching(vector<vector<int>>& adj, int m, int n) {
    vector<int> matched(n + 1, 0);
    vector<bool> visited(n + 1);
    int count = 0;
    for(int u = 1; u <= m; u++) {
        visited.assign(visited.size(), false);
        if(dfsFindAlterPaths(adj, matched, visited, u)) {
            ++count;
        }
    }
    return count;
}

int main() {
    int m, n, e;
    cin>>m>>n>>e;
    vector<vector<int>> adj(m + 1, vector<int>());
    int u,v;
    for(int i=0; i<e; i++) {
        cin>>u>>v;
        adj[u].push_back(v);
    }
    cout << maxPartiteMatching(adj, m , n);
    return 0;
}

/* Test Case1:
4 2 7
3 1
1 2
3 2
1 1
4 2
4 1
1 1
*/

